< previous page page_305 next page >

Page 305
Note
This is exactly the same as if you coded
PropertyPage.Changed = True.

Notifying the PropertyPage object that values have changed enables the Apply button on the Property Pages dialog box and causes the ApplyChanges event to occur when the following occurs:
8694cbadb9b1ef7075903f6f95fc1db2.gif
The Apply button is pressed.
8694cbadb9b1ef7075903f6f95fc1db2.gif
Users change pages.
8694cbadb9b1ef7075903f6f95fc1db2.gif
The dialog box is closed.
The last routine you need to worry about and the second most important event in a PropertyPage object is the ApplyChanges event. In this event, you copy the changed property values back to the currently selected control. The following code is an example of this routine coded for your new control:
Private Sub PropertyPage_ApplyChanges()
    SelectedControls(0).TableName = txtTableName.Text
    SelectedControls(0).DisplayField = txtDisplayField.Text
End Sub
In this example, there is little chance for an error to occur in the ApplyChanges event. However, if your Property Page allows users to enter values that may be rejected by the Property Let (or Property Set) procedure in the control's code, you should use error trapping in the ApplyChanges event. The simplest scheme is to use On Error ResumeNext and test Err.Number after each property that may raise an error. When an error occurs, you should do the following:
8694cbadb9b1ef7075903f6f95fc1db2.gif
Stop processing the ApplyChanges event.
8694cbadb9b1ef7075903f6f95fc1db2.gif
Display an error message, so users understand what went wrong.
8694cbadb9b1ef7075903f6f95fc1db2.gif
Set the focus to the property that caused the error.
8694cbadb9b1ef7075903f6f95fc1db2.gif
Set the Changed property of the PropertyPage object to True.
Note
Setting
Changed to True re-enables the Apply button and prevents the Property Pages dialog box from being closed if users click OK.

 
< previous page page_305 next page >

If you like this book, buy it!